package com.videoweb.mapper;

import com.videoweb.entity.Tag;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;


/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author lmr
 * @since 2025-05-17
 */

@Mapper
public interface TagMapper extends BaseMapper<Tag> {

    void batchInsertTags(List<Tag> tags);


    List<Long> findTagIdsByNames(@Param("tagNames") List<String> tagNames);


//    根据视频的ID来得到其有的标签
    @Select("SELECT t.id, t.name " +
            "FROM video_tag vt " +
            "INNER JOIN tag t ON vt.tag_id = t.id " +
            "WHERE vt.video_id = #{videoId}")  //
    List<Tag> getTagsByVideoId(@Param("videoId") Long videoId);

}
